package com.shanyi.sendmsg.biz;

import com.baidubce.model.ApiExplorerResponse;
import com.shanyi.sendmsg.dto.enums.CityEnum;
import com.shanyi.sendmsg.dto.enums.WarmInfoEnum;
import com.shanyi.sendmsg.dto.req.WeatherQueryReqDto;
import com.shanyi.sendmsg.tool.BaiduWeather;
import com.shanyi.sendmsg.tool.RobotTool;
import com.shanyi.sendmsg.tool.WeaJson2Object;
import com.shanyi.sendmsg.tool.WeaObject2Str;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service
public class SendMsgBiz {
    
    @Resource
    private BaiduWeather baiduWeather;
    @Resource
    private WeaJson2Object weaJson2Object;
    @Resource
    private WeaObject2Str weaObject2Str;

    public String sendMsgBiz() {

        ApiExplorerResponse changchun = baiduWeather.baiduWeather(new WeatherQueryReqDto(CityEnum.changchun.getCity(), CityEnum.changchun.getCityId(), "", CityEnum.changchun.getProvince()));
        ApiExplorerResponse hangzhou = baiduWeather.baiduWeather(new WeatherQueryReqDto(CityEnum.hangzhou.getCity(), CityEnum.hangzhou.getCityId(), "", CityEnum.hangzhou.getProvince()));
        ApiExplorerResponse jinan = baiduWeather.baiduWeather(new WeatherQueryReqDto(CityEnum.jinan.getCity(), CityEnum.jinan.getCityId(), "", CityEnum.jinan.getProvince()));
        ApiExplorerResponse shanghai = baiduWeather.baiduWeather(new WeatherQueryReqDto(CityEnum.shanghai.getCity(), CityEnum.shanghai.getCityId(), "", CityEnum.shanghai.getProvince()));
        ApiExplorerResponse shenyang = baiduWeather.baiduWeather(new WeatherQueryReqDto(CityEnum.shenyang.getCity(), CityEnum.shenyang.getCityId(), "", CityEnum.shenyang.getProvince()));

        String s1 = WeaObject2Str.weaObject2Str(WeaJson2Object.weaJson2Object(changchun.getResult()));
        String s2 = WeaObject2Str.weaObject2Str(WeaJson2Object.weaJson2Object(hangzhou.getResult()));
        String s3 = WeaObject2Str.weaObject2Str(WeaJson2Object.weaJson2Object(jinan.getResult()));
        String s4 = WeaObject2Str.weaObject2Str(WeaJson2Object.weaJson2Object(shanghai.getResult()));
        String s5 = WeaObject2Str.weaObject2Str(WeaJson2Object.weaJson2Object(shenyang.getResult()));
        
        String head = "Java定时机器人发送群消息:" + "\n";
        String warmInfo = "每日名句:" + WarmInfoEnum.warm_info_2.getMsg() + "\n";
        
        String sendMsg = s1 + "\n"
                + s2 + "\n"
                + s3 + "\n"
                + s4 + "\n"
                + s5;

        RobotTool robotTool = new RobotTool();
        
        String msg = head + warmInfo + sendMsg;
        System.out.println(msg);
        return robotTool.robotSendMsg(msg);
    }
}
